package com.tjp.eight.ui.fragment.whozan;

import com.tjp.eight.AllRetrofit;
import com.tjp.eight.base.BasePresenterImpl;
import com.tjp.eight.constant.UrlConstant;
import com.tjp.eight.net.NetCallBack;
import com.tjp.eight.net.SubscribeCallBack;

import okhttp3.MediaType;
import okhttp3.RequestBody;

/**
 * Created by Administrator on 2017/3/2.
 */
public class WhoZanPresenter extends BasePresenterImpl<WhoZanView>{
    public WhoZanPresenter(WhoZanView view) {
        attachView(view);
    }

    WhoZanService whoZanService = AllRetrofit.getRetrofit(UrlConstant.BaseUrl).create(WhoZanService.class);
    public void loadData(String postJson) {
        RequestBody r = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), postJson);
        addSubscription( whoZanService.loadData(r), new SubscribeCallBack<>(new NetCallBack<WhoZanResultModel>() {
            @Override
            public void onSuccess(WhoZanResultModel model) {
                view.loadSuccess(model);
            }

            @Override
            public void onFails(int code, String msg) {
                view.loadError(msg);
            }

            @Override
            public void onCompleted() {

            }
        }));
    }
}
